//
//  SEExamineTitleMemoView.swift
//  SmartEyeForPatient
//
//  Created by qdsg on 2021/4/9.
//

import UIKit

@IBDesignable class SEExamineTitleMemoView: UIView {

    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var memoLabel: UILabel!

    override init(frame: CGRect) {
        super.init(frame: frame)
        setUI()
    }

    required init?(coder: NSCoder) {
        super.init(coder: coder)
        setUI()
    }

    @IBInspectable var titleText: String? {
        get {
            return titleLabel.text
        }
        set {
            titleLabel.text = newValue
        }
    }

    @IBInspectable var titleTextColor: UIColor? {
        get {
            return titleLabel.textColor
        }
        set {
            titleLabel.textColor = newValue
        }
    }

    @IBInspectable var memoText: String? {
        get {
            return memoLabel.text
        }
        set {
            memoLabel.text = newValue
        }
    }

    @IBInspectable var memoTextColor: UIColor? {
        get {
            return memoLabel.textColor
        }
        set {
            memoLabel.textColor = newValue
        }
    }

    @IBInspectable var memoLabelAlignment: Int {
        get {
            return memoLabel.textAlignment.rawValue
        }
        set {
            memoLabel.textAlignment = NSTextAlignment(rawValue: newValue) ?? .left
        }
    }

    func setUI() {
        loadNib()
    }

    func loadNib() {
        let view = UINib.init(nibName: String(describing: type(of: self)), bundle: Bundle(for: type(of: self))).instantiate(withOwner: self, options: nil).last as! UIView
        view.frame = bounds
        addSubview(view)
    }

}
